import speech_recognition as sr

def audio_to_text(audio_path):
    recognizer = sr.Recognizer()
    with sr.AudioFile(audio_path) as source:
        audio = recognizer.record(source)
    try:
        text = recognizer.recognize_google(audio, language='zh-CN')
        return text
    except Exception as e:
        print(f"语音识别失败: {e}")
        return None 